#ifndef SEARCHWINDOW_H
#define SEARCHWINDOW_H

#include <assert.h>
#include <QMainWindow>
#include <QString>
#include <QMessageBox>

// changed to QDialog
//#include "ui_searchwindow.h"
#include "ui_searchdialog.h"
#include <fstream>
#include <QDir>
#include "searchitem.h"

#include <QList>
#include "includes/phrase.h"
#include "includes/thesaurus.h"

/**
 * A search window which is used to look for phrases in the thesaurus.
 * By using this dialog box, users can search for relevant phrases to learn
 * which may be relevant to what they are looking for.
 *
 * All the Phrase's in the program are access through the Thesaurus object,
 * which maintains the hash table itself.
 *
 * Uses the autogenerated class Ui::SearchDialog, which comes from the Qt
 * Designer form <i>searchdialog.ui</i>.
 *
 * @see Thesaurus
 * @see MainWindow
 * @author Lawrence, Sarah and Ronen
 */
class SearchWindow : public QDialog, public Ui::SearchDialog
{
    Q_OBJECT
    // PRIVATE MEMBERS ////////////////////////////
private:
    //variables
    /*std::vector<searchItem> searchItems;
    QString dir; //current working directory*/
    // pointer to thesaurus
    Thesaurus* thesaurus;
public:
    // CONSTRUCTORS ///////////////////////////////
    SearchWindow();
    ~SearchWindow();
    /**
     * Create the Qt widget connections for this dialog.
     */
    void startConnections();
    /**
     * Search for a word and show the results in the list widget.
     * @param The word to search for. The names of all Phrase's as
     * well as all their synonyms and partial matches will be included
     * in this search.
     */
    void searchAndShow(QString text);
    /**
     * Bind this dialog box to a populated Thesaurus which contains
     * all the words and the Phrase's they map to.
     * @param The thesaurus to use for this dialog.
     * @see Thesaurus
     */
    void setThesaurus(Thesaurus*t);

    // perform thesaurus lookup. thin wrapper for hashtable lookup
    QList<Phrase*> find(QString name);

    void updateListWidget(QString text);
    void removeDuplicates();
    QString getImageName();
    QString getVideoName();
    // SLOTS //////////////////////////////////////////
public slots:
    /**
     * Update the search results as the user types, and clear
     * them when the text field is blank.
     */
    void typingFinished();
};

#endif // SEARCHWINDOW_H
